package com.cy.pj.sys.controller;

import com.cy.pj.common.pojo.JsonResult;
import com.cy.pj.sys.entity.SysUser;
import com.cy.pj.sys.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class SysUserController {

    @Autowired
    private SysUserService sysUserService;

    @RequestMapping("/user/doFindPageObjects")
    public JsonResult doFindPageObjects(String username,Integer pageCurrent){
       return new JsonResult(sysUserService.findPageObjects(username,pageCurrent));
    }

    @RequestMapping("/user/doValidById")
    public JsonResult doValidById(Integer id,Integer valid){
        sysUserService.validById(id, valid);
        return new JsonResult("update OK");
    }

    @RequestMapping("/user/doSaveObject")
    public JsonResult doSaveObject(
            SysUser entity,Integer[] roleIds){
        sysUserService.saveObject(entity, roleIds);
        return new JsonResult("save Ok");
    }


    @RequestMapping("/dept/doFindZTreeNodes")
    public  JsonResult doFindZtreeUserNodes(){
        return new JsonResult(sysUserService.findZtreeUserNodes());
    }
}
